package com.ddfeiyu.client;

import com.ddfeiyu.agreement.codec.ObjDecoder;
import com.ddfeiyu.agreement.codec.ObjEncoder;
import com.ddfeiyu.client.handler.LogHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

public class NettyClientChannelInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        // 对象传输处理[解码]
        pipeline.addLast(new ObjDecoder());
        // 在管道中添加我们自己的接收数据实现方法
        pipeline.addLast(new LogHandler());
        // 对象传输处理[编码]
        pipeline.addLast(new ObjEncoder());
    }
}
